/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jpa.bean;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 *
 * @author luis
 */

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


@Entity
@Table(name = "usuario")
@NamedQuery(name = "Usuario.findAll", query = "select o from Usuario o order by o.cod_user")
@SequenceGenerator(name = "seqUsuario", sequenceName = "SEQUSUARIO", allocationSize = 1)
public class Usuario implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "seqUsuario")
    private int cod_user;
    @Column(nullable = false)
    private String login, senha;

    public Usuario() {
    }

    public Usuario(int cod_user, String login, String senha) {
        this.cod_user = cod_user;
        this.login = login;
        this.senha = senha;
    }

    public int getCod_user() {
        return cod_user;
    }

    public void setCod_user(int cod_user) {
        this.cod_user = cod_user;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getSenha() {
        return senha;
    }

    public void setSenha(String senha) {
        this.senha = senha;
    }

    @Override
    public String toString() {
        return this.login;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 41 * hash + this.cod_user;
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Usuario other = (Usuario) obj;
        if (this.cod_user != other.cod_user) {
            return false;
        }
        return true;
    }
}
